package com.zou.controller.backstage;

import com.zou.commons.constants.Constants;
import com.zou.pojo.Manager;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller("backstageIndex")
public class IndexController {

    /**
     * 进入首页
     *
     * @return
     */
    @RequestMapping("/backstage/index")
    public String index(HttpSession session, Model model) {
        Manager manager = (Manager) session.getAttribute(Constants.SESSION_USER);
        model.addAttribute("imgUrl", "images/y.jpg");
        return "backstage/index.html";
    }

    /**
     * 进入展示页
     *
     * @return
     */
    @GetMapping("/backstage/main")
    public String toMain() {
        return "backstage/main.html";
    }

    /**
     * 退出登录
     *
     * @param session
     * @return
     */
    @GetMapping("/backstage/goOut")
    public String goOut(HttpSession session) {
        // 移除session
        session.removeAttribute(Constants.SESSION_USER);
        return "redirect:login";
    }
}
